package com.qingcloud.wcenter.model;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@Data
public class TablePageParams implements Serializable {

    @ApiModelProperty(value = "第多少页(从0开始)", example = "0")
    private Integer page;

    @ApiModelProperty(value = "每页显示记录数", example = "10")
    private Integer length;

    @ApiModelProperty(value = "分页偏移量", example = "0", hidden = true)
    private Integer offset;

    @ApiModelProperty(value = "排序字段,预警次数(totalCount),预警频率(totalRate)", example = "iaqi")
    private String sortField;

    @ApiModelProperty(value = "排序方向", example = "DESC", allowableValues = "ASC,DESC")
    private String direction;

    public Integer getOffset() {
        if (page != null && length != null) {
            return page * length;
        }
        return 0;
    }
}
